package top.hekun.study.core.visitor.simple;

import org.objectweb.asm.*;

/**
 * 〈更改类的版本〉
 *
 * @author: Sakura
 * @date: 2023/5/8
 */
public class MyClassVisitor1 extends ClassVisitor {
    public MyClassVisitor1(int apiVersion, ClassVisitor classWriter) {
        super(apiVersion, classWriter);
    }

    /**
     * 构造方法
     *
     * @param version
     * @param access
     * @param name
     * @param signature
     * @param superName
     * @param interfaces
     */
    @Override
    public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
        System.out.println("MyClassVisitor1:visit");
        // 抛弃原有版本, 更改为1.7版本
        super.visit(Opcodes.V1_7, access, name, signature, superName, interfaces);
    }
    @Override
    public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
        System.out.println("MyClassVisitor1:visitField -- " + name);
        return super.visitField(access, name, descriptor, signature, value);
    }
    @Override
    public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
        System.out.println("MyClassVisitor1:visitMethod -- " + name + " -- " + descriptor);
        return super.visitMethod(access, name, descriptor, signature, exceptions);
    }
    @Override
    public void visitEnd() {
        System.out.println("MyClassVisitor1:visitEnd");

        super.visitEnd();
    }
}
